<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Comment
 *
 * @property int $id
 * @property int $uid 用户id
 * @property int $goods_id 商品id
 * @property string $comment 评论内容
 * @property string $avatar 用户头像
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property-read \App\Models\Goods $goods
 * @property-read \App\Models\Customer $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereAvatar($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereComment($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereGoodsId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Comment whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Comment extends Model
{
    protected $table='user_comments';

    protected $guarded=[];

    public function user()
    {
        return $this->belongsTo('App\Models\Customer','uid');
    }

    public function goods()
    {
        return $this->belongsTo('App\Models\Goods','goods_id');
    }

    public function destroyData($id)
    {
        $result = $this->destroy($id);
        if($result){
            return true;
        }else{
            return false;
        }
    }
}
